<?php 
class MessageController extends AdminController
{
	public function actionIndex()
	{
		$model=new Message('search');
		$model->unsetAttributes();  // clear any default values
		if(isset($_GET['Message']))
			$model->attributes=$_GET['Message'];

		$this->render('search/index',array(
			'model'=>$model,
		));
	}

	public function actionHistory($id) {
		$model=new Message('search');
		$model->unsetAttributes();  // clear any default values
		$model->belong_to= $id;
		$user = User::model()->findByPk($id);
		$this->render('history',array(
			'model'=>$model,
			'user'=>$user,
		));
	}
	
	public function actionNg() {
		$model=new NGWordForm();
		$model->content = $model->buildNGWordList();
		
		if(isset($_POST['NGWordForm']))
		{
			$model->attributes=$_POST['NGWordForm'];
			if($model->validate()) {
				$model->saveNGWordList();
				Yii::app()->user->setFlash('success',Yii::t('app', 'Data has been saved'));
				$this->redirect(array('ng'));
			}
		}		
		$this->render('ngword',array(
			'model'=>$model,
		));
	}
}